@using System.Globalization
@using Abp.Extensions
@using Abp.MultiTenancy
@using Yozeev.Identity
@using Yozeev.Web.Portal.Startup.Navigation
@model Yozeev.Web.Portal.Models.Account.LoginFormViewModel
@inject SignInManager SignInManager

@{
    ViewBag.CurrentPageName = PortalNavPageNames.Login;
}

@section Scripts
    {

    <script src="~/pages/account/login.js" asp-append-version="true"></script>
}

@section Styles
    {

}
<!-- Login Form -->
<div class="container position-relative space-2">
    <form class="js-validate loginForm w-md-75 w-lg-50 mx-md-auto" action="@Url.Action("Login","Account")" method="post">
        <input type="hidden" name="returnUrl" value="@Model.ReturnUrl" />
        <input type="hidden" name="returnUrlHash" />
        @Html.AntiForgeryToken()

        <!-- Title -->
        <div class="mb-7">
            <h2 class="h3 text-primary font-weight-normal mb-0">
                欢迎 <span class="font-weight-semi-bold">
                    回到52ABP
                </span>
            </h2>
            <p>
                登录您的账号，使用52ABP创建您的项目。52ABP 是终身学习者的编程知识社区
                保持好奇，刻意练习，每日精进。
            </p>
        </div>

        <!-- End Title -->
        <!-- Form Group -->
        <div class="js-form-message form-group">
            <label class="form-label" for="usernameOrEmailAddress">@L("UserNameOrEmailOrCellphone")</label>
            <input type="text" class="form-control" id="usernameOrEmailAddress" name="usernameOrEmailAddress" placeholder="请输入用户名/邮箱/手机号" aria-label="请输入用户名/邮箱/手机号" required
                   data-msg="请输入用户名/邮箱/手机号信息。"
                   data-error-class="u-has-error"
                   data-success-class="u-has-success">
        </div>
        <!-- End Form Group -->
        <!-- Form Group -->
        <div class="js-form-message form-group">
            <label class="form-label" for="password">
                <span class="d-flex justify-content-between align-items-center">
                    @L("Password")

                </span>
            </label>
            <input type="password" class="form-control" id="password" name="password" placeholder="********" aria-label="********" required
                   data-msg="您的密码无效，请重新尝试。"
                   data-error-class="u-has-error"
                   data-success-class="u-has-success">
        </div>

        <div class="custom-control custom-checkbox custom-control-inline mb-3">
            <input type="checkbox" class="custom-control-input" id="rememberMe" name="rememberMe">
            <label class="custom-control-label " for="rememberMe">
                @L("RememberMe")
            </label>


        </div>
        <div class="custom-control custom-checkbox custom-control-inline float-right mb-3">
            <span class="small text-muted">您如果还没有账号？请</span>
            <a class="small mr-1" href="@Url.Action("Register","Account")">注册</a>
            <span class="small text-muted"> 还是说    </span>

            <a class="small ml-1" href="@Url.Action("ForgotPassword","Account")">@L("ForgotPassword")?</a>

        </div>


        <!-- Button -->

        <div class="row align-items-center mb-5">
            <button type="submit" class="btn btn-primary  btn-block transition-3d-hover">登录</button>

        </div>
        <!-- End Button -->
    </form>

    @{
        var loginProviders = (await SignInManager.GetExternalAuthenticationSchemesAsync())
            .Where(s => !s.DisplayName.IsNullOrWhiteSpace())
            .ToList();

        Func<string, string> getSocialIconClass = (provider) =>
        {
            provider = provider.ToLower(CultureInfo.InvariantCulture);

            return provider;
        };
    }

    @if ( loginProviders.Count > 0)
    {
    <div class="js-validate loginForm w-md-75 w-lg-50 mx-md-auto">
        <div class="row align-items-center mb-5">
            <span class="split-line">
                其他方式登录
            </span>
        </div>                <div class="row align-items-center mb-5">

            @foreach (var p in loginProviders)
            {

                <div class="col-md-4 ">

                    <a class="btn btn-block btn-sm btn-soft-indigo  btn-soft-@(p.Name.ToLower()) transition-3d-hover mb-1 mr-1" href="javascript:document.forms['@("ExternalLogin" + p.Name)'].submit();">
                        <span class="fab fa-@getSocialIconClass(p.DisplayName) mr-1"></span>
                        @p.DisplayName
                    </a>
                    <form style="display: none;" asp-action="ExternalLogin" name="@("ExternalLogin" + p.Name)" method="post">
                        <input type="hidden" name="provider" value="@p.Name" />
                        <input type="hidden" name="returnUrl" value="@Model.ReturnUrl" />
                    </form>
                </div>


            }
        </div>
    </div>
    }
</div>
<!-- End Login Form -->
